package com.ysxsoft.wdg.ui.fragment;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.adapter.ht.HtAdapter;
import com.ysxsoft.wdg.base.BaseFragment;
import com.ysxsoft.wdg.ui.activity.ht.HtDetailActivity;
import com.ysxsoft.wdg.ui.activity.ht.HtPublishActivity;
import com.ysxsoft.wdg.util.ViewUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class HTaoFragment extends BaseFragment {
    @BindView(R.id.topView)
    View topView;
    @BindView(R.id.title_finish)
    ImageView titleFinish;
    @BindView(R.id.title_content)
    TextView titleContent;
    @BindView(R.id.title_iv_r)
    ImageView titleIvR;
    @BindView(R.id.tabLayout)
    TabLayout tabLayout;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout refreshLayout;


    private HtAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.fm_four;
    }

    @Override
    protected void initData() {
        initStatusBar(topView, false);

        titleFinish.setVisibility(View.GONE);
        titleIvR.setImageResource(R.mipmap.ht_fb);
        titleContent.setText("汇淘");


        tabLayout.addTab(tabLayout.newTab().setText("关注"));
        tabLayout.addTab(tabLayout.newTab().setText("爱生活"));
        tabLayout.addTab(tabLayout.newTab().setText("爱时尚"));
        tabLayout.addTab(tabLayout.newTab().setText("爱美妆"));
        tabLayout.addTab(tabLayout.newTab().setText("视频"));
        tabLayout.addTab(tabLayout.newTab().setText("运动"));
        tabLayout.addTab(tabLayout.newTab().setText("美食"));
        tabLayout.addTab(tabLayout.newTab().setText("摄影"));

        ViewUtils.tabRelex(tabLayout);

        adapter = new HtAdapter(R.layout.item_ht);
        recyclerview.setLayoutManager(new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL));
        recyclerview.setAdapter(adapter);
    }

    @Override
    protected void setListener() {
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                HtDetailActivity.start(mContext,"");
            }
        });
    }


    @OnClick(R.id.title_iv_r)
    public void onViewClicked() {
        startActivity(new Intent(mContext, HtPublishActivity.class));
    }

}
